<template>
    <h1>用户借款项目信息</h1>

    <table>
        <thead>
            <tr>
                <th>借款人</th>
                <th>借款金额</th>
                <th>借款时间</th>
                <th>借款项目名称</th>
                <th>借款年限</th>
                <th>借款利息</th>
                <th>操作</th>
            </tr>
        </thead>

        <tbody>
            <tr  v-for="item in Info">
                <td>{{ item.UI_Name}}</td>
                <td>{{ item.UB_Money }}</td>
                <td>{{ item.UB_Date.substring(0,10)}}</td>
                <td>{{ item.BM_Name }}</td>
                <td>{{ item.BM_Year }}</td>
                <td>{{ item.BI_Name }}</td>
                <td>
                    <a href="#"  @click="jump(item.UB_Id)">还款</a>
                </td>
            </tr>
        </tbody>

    </table>

</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue';
import {useStore} from '../../store/index';
import axios from 'axios';
import { useRouter } from 'vue-router';

const Info = ref([{
    UI_Name:'',
    UB_Id:0,
    UB_Money:0,
    UB_Date:'',
    BM_Name:'',
    BM_Year:0,
    BI_Name:0,
}])

const router = useRouter();

const store = useStore();

console.log(store.Uid);

onMounted (()=>{
    axios({
        method:'get',
        url:"http://localhost:61480/api/Borrow/UserBorrowShowData",
        params:{
            UId:store.Uid
        }
    })
    .then((res)=>{
        console.log(res.data);
        
        Info.value = res.data;
    })
    .catch((err)=>{
        console.log(err);
    })
})

const jump = (UBId:number)=>{
    router.push({
        name:'AddUserRedeem',
        params:{
            UBId:UBId
        }
    })
}

</script>
